package org.jeecg.modules.kc.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.kc.entity.KcDepositoryInGoods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.kc.entity.KcSupplierInGoods;
import org.jeecg.modules.kc.vo.GoodStorage;

/**
 * @Description: kc_depository_in_goods
 * @Author: jeecg-boot
 * @Date:   2023-04-18
 * @Version: V1.0
 */
public interface KcDepositoryInGoodsMapper extends BaseMapper<KcDepositoryInGoods> {

    /**
     * 仓库库存商品列表
     * @param page
     * @param hotelId
     * @param goodsName
     * @param depositoryId
     * @return
     */
    @Select("<script>select sg.*,g.name as goods_name,g.stock_warning,gt.name as goods_unit_name,g.spec as goods_spec,ksd.price as price,ksd.stock_id as stock_code " +
            "from kc_depository_in_goods sg inner join ces_goods g on g.id=sg.goods_id\n" +
            "left join ces_goods_unit gt on gt.id=g.good_unit\n" +
            "inner join kc_stock_detail ksd on ksd.id = sg.stock_detail_id " +
            "where 1=1\n" +
            "<if test='goodId != null and goodId !=\"\"'> and sg.goods_id = #{goodId} </if>"+
            "<if test='depositoryId != null and depositoryId !=\"\"'> and sg.depository_id = #{depositoryId} </if>"+
            "<if test='hotelId != null and hotelId !=\"\"'> and sg.hotel_id = #{hotelId} </if>"+
            "<if test='goodsName != null and goodsName !=\"\"'> and g.name like concat('%',#{goodsName},'%') </if>"+
            "</script>")
    public List<KcDepositoryInGoods> depositoryInGoodsList(Page<KcDepositoryInGoods> page, String hotelId, String goodsName,String depositoryId,String goodId);

    IPage<GoodStorage> storagePage(Page<GoodStorage> page,@Param("goodStorage") GoodStorage goodStorage);

    IPage<GoodStorage> storageDetailPage(Page<GoodStorage> page, GoodStorage goodStorage);

    IPage<GoodStorage> goodsSellDetailPage(Page<GoodStorage> page, GoodStorage goodStorage);

    IPage<GoodStorage> goodsSellCollect(Page<GoodStorage> page, GoodStorage goodStorage);
}
